package com.eastfair.enums;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 当前环境枚举类
 *
 * </p>
 *
 * @author zjn
 * @date 2021-07-29
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ProfilesActiceEnum", description = "当前环境 #{DEV:开发环境;TEST:测试环境;PROD:生产环境")
public enum ProfilesActiveEnum implements BaseEnum {

    /**
     * VISITOR="观众"
     */
    DEV("开发环境"),
    /**
     * EXHIBITOR="展商"
     */
    TEST("测试环境"),
    /**
     * SPONSOR="主办"
     */
    PROD("生产环境"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ProfilesActiveEnum match(String val, ProfilesActiveEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ProfilesActiveEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ProfilesActiveEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "DEV,TEST,PROD", example = "VISITOR")
    public String getCode() {
        return this.name();
    }

}
